/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements.  See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License.  You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/


/*************************************************************************
 * File: http.h
 *************************************************************************
 *\author: starlove
 *************************************************************************/

#ifndef __MLSE_LIBRARY_HTTP_H__
#define __MLSE_LIBRARY_HTTP_H__

#include <network/network.h>
#include <codec/exdata_wrapper.h>
#include <codec/exdata.h>

#define __MLSE_NETWORK_HTTP_RQUEST_MINSIZE__ 	14
#define __MLSE_NETWORK_HTTP_RQUEST_MAXSIZE__ 	(128 * 1024)
#define __MLSE_NETWORK_HTTP_LINE_DELIMITERS__ 	"\r\n"
#define __MLSE_NETWORK_HTTP_HEADER_DELIMITERS__ "\r\n\r\n"
#define __MLSE_NETWORK_HTTP_KEY_DELIMITERS__ 	":"
#define __MLSE_NETWORK_HTTP_404_RESPONSE__ 		"HTTP/1.1 404 Not Found\r\n\r\n404 Not Found"

#define __MLSE_NETWORK_HTTP_GET__ 		1
#define __MLSE_NETWORK_HTTP_POST__ 		2
#define __MLSE_NETWORK_HTTP_HEAD__ 		3
#define __MLSE_NETWORK_HTTP_OPTIONS__ 	4

#define __MLSE_NETWORK_HTTP_VER_1__ 	1
#define __MLSE_NETWORK_HTTP_VER_0__ 	0


class CHTTPParser
{
public:
	static int parse_length(const char *, unsigned int);
	static bool parse_request_action(const char *, LPHTTP_ACTION);
	static const char *get_method_name(char);
	static bool build_response(LPNETWORKBUFFER, LPHTTPRESPONSE, LPNETWORKBUFFER);
};

#endif // __MLSE_LIBRARY_HTTP_H__
